1. Field
The disclosure relates generally to data processing system and more specifically to cache management in data processing systems. Even more specifically, the disclosure relates to insertion of data in a cache.
2. Description of the Related Art
Caches are commonly used in data processing systems to store data for use by one or more processors. When a processor requests data from memory, the data is loaded into the cache from a memory, such as main memory or another cache. A cache may be comprised of memory that has a faster access time than the memory from which the cache is loaded. For example, a level 2 cache has a faster access time than main memory, and a level 1 cache has faster access time than the level 2 cache. In some illustrative examples, data processing systems contain smaller amounts of memory with faster access time to reduce the cost of manufacturing the data processing system.
The data is stored in the cache because a processor may access the same data multiple times. Retrieving the data from the cache is faster than retrieving the data from a lower level cache or main memory. A lower level cache is a cache that is separated from a processor by more levels of cache than a higher level cache. For example, an L2 cache located outside a processor unit is a lower level cache than an L1 cache located within the processor unit.
Because a cache is commonly smaller than the memory from which the cache data is loaded, the cache may implement several techniques to manage the cache. For example, a cache may be associative and be designed with multiple ways. An associative cache with multiple ways is designed such that a particular group of locations in main memory may be stored in any of a particular number of positions within the cache. For example, each cache set in an 8 way associative cache may store data from 8 memory addresses within a particular portion of main memory at a particular time.
Another technique used to manage the cache is a replacement process. In a cache with multiple ways, data in the cache may be overwritten to store data requested by the processor that is not presently stored within the cache. One replacement process is a least recently used (LRU) process. In a cache that implements a least recently used process, the data in each way of a cache is ranked according to the order the data was accessed by a processor unit. In other words, the data in each way is ranked from most recently used to least recently used. When a processor requests data not presently stored in the cache, the data is stored in the position in the way that holds the rank of least recently used.
Cache management is more challenging when multiple threads are running on a processor unit and using the same cache. The threads may not use memory in the same way. For example, one thread may use the same data very frequently, while another thread frequently uses data only once.